package com.onedec.attendance.controller;


import com.onedec.attendance.utils.AttendUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class AttendanceController {

    @PostMapping("/morningattend")
    public String addMorningAttend(Double longitude, Double latitude, Double height, HttpServletRequest req){
        System.out.println("进入早上打卡");
        System.out.println(AttendUtil.getDistance(longitude,latitude));
        if (AttendUtil.getDistance(longitude,latitude)<=100&&height-AttendUtil.HEIGHT<=20){
            System.out.println("打卡成功！");
            return "打卡成功";
        }else {
            System.out.println("打卡失败！");
            return "打卡失败";
        }
    }

    @PostMapping("/afternoonattend")
    public String addAfternoonAttend(Double longitude, Double latitude, Double height, HttpServletRequest req){
        System.out.println("进入下午打卡");
        System.out.println(AttendUtil.getDistance(longitude,latitude));
        if (AttendUtil.getDistance(longitude,latitude)<=100&&height-AttendUtil.HEIGHT<=20){
            System.out.println("打卡成功！");
            return "打卡成功";
        }else {
            System.out.println("打卡失败！");
            return "打卡失败";
        }
    }
}
